<template>
  <div>
    <uni-forms :label-width="120" ref="enter" :value="entering" validate-trigger="bind" class="form">
      <uni-row>
        <uni-col :xs="24" :sm="12">
          <uni-forms-item name="batchNumber" label-align="right" label="批号 : " required>
            <uni-easyinput v-model="entering.batchNumber" @blur="getInfo"></uni-easyinput>
          </uni-forms-item>
        </uni-col>
        <uni-col :xs="24" :sm="12">
          <uni-forms-item name="bugType" label-align="right" label="幼虫类型 : " required>
            <uni-data-select
                v-model="entering.bugType"
                :localdata="bugTypeList"
            ></uni-data-select>
          </uni-forms-item>
        </uni-col>
        <uni-col :xs="24" :sm="12">
          <uni-forms-item name="reloadingStyle" label-align="right" label="换料日期方式 : " required>
            <uni-data-select
                v-model="entering.reloadingStyle"
                :localdata="reloadingType"
            >
            </uni-data-select>
          </uni-forms-item>
        </uni-col>
        <uni-col :xs="24" :sm="12">
          <uni-forms-item name="nextReloadingDate" label-align="right" label="下次换料日期 : " required>
            <uni-datetime-picker
                type="date"
                :clear-icon="false"
                v-model="entering.nextReloadingDate"
                :start="parseTime(new Date(),'{y}-{m}-{d}')"
            />
          </uni-forms-item>
        </uni-col>
        <uni-col :xs="24" :sm="12">
          <uni-forms-item name="sum" label-align="right" label="数量 : " required>
            <uni-easyinput type="number" v-model="entering.sum"></uni-easyinput>
          </uni-forms-item>
        </uni-col>
        <uni-col :xs="24" :sm="12">
          <uni-forms-item name="optionDate" label-align="right" label="挑虫日期 : " required>
            <uni-datetime-picker
                type="date"
                :clear-icon="false"
                :value="entering.optionDate"
                v-model="entering.optionDate"
				@change="getDate"
            />
          </uni-forms-item>
        </uni-col>
        <uni-col :xs="24" :sm="12">
          <uni-forms-item name="digoutInfection" label-align="right" label="出土侵染率 : ">
            <uni-easyinput type="number" v-model="entering.digoutInfection"></uni-easyinput>
          </uni-forms-item>
        </uni-col>
        <uni-col :xs="24" :sm="12">
          <uni-forms-item name="digoutMonth" label-align="right" label="出土月份 : " required>
            <uni-title :title="entering.digoutMonth" type="h3" @click="handleShow"></uni-title>
            <select-month v-model="entering.digoutMonth"
                          :disabled-date="()=>false" v-model:visible="showPicker">
            </select-month>
          </uni-forms-item>
        </uni-col>
        <uni-col :xs="24" :sm="12">
          <uni-forms-item label-align="right" label="车间 : " required>
            <uni-easyinput v-model="deptName" disabled></uni-easyinput>
          </uni-forms-item>
        </uni-col>
        <uni-col :xs="24" :sm="12">
          <uni-forms-item name="roomId" label-align="right" label="养虫间 : " required>
            <uni-data-select
                v-model="entering.roomId"
                :localdata="roomList"
            ></uni-data-select>
          </uni-forms-item>
        </uni-col>
        <uni-col :span="24">
          <uni-forms-item label-align="right" label="备注 : ">
            <uni-easyinput v-model="entering.remark"></uni-easyinput>
          </uni-forms-item>
        </uni-col>
      </uni-row>
      <button form-type="submit" class="button" @click="handleSubmit">{{title}}
      </button>
    </uni-forms>

  </div>
</template>

<script setup lang="ts">


import {onMounted, reactive, ref, watch} from "vue";
import {inputFormService} from "../../pagesVM/input";
import {onLoad, onReady} from "@dcloudio/uni-app";
import SelectMonth from '../../components/select-month/index'
import {parseTime} from "../../util/auth";
import UniEasyinput from "../../uni_modules/uni-easyinput/components/uni-easyinput/uni-easyinput.vue";


const {
  entering,
  getInfo,
  reloadingType,
  bindDateChange,
  deptName,
  roomList,
  getRoomList,
  enter,
  rules,
  handleSubmit,
  getDate,
    title
} = inputFormService()

onReady(() => {
  enter.value.setRules(rules)
})


const showPicker = ref(false)
const bugTypeList = [{
  text: 'C-YZ',
  value: 'C-YZ'
}, {
  text: 'C-QR',
  value: 'C-QR'
}, {
  text: 'G-YZ',
  value: 'G-YZ'
}, {
  text: 'G-QR',
  value: 'G-QR'
}]
const handleShow = () => {
  showPicker.value = true
}

</script>

<style scoped>
.form {
  /*margin-top: 50px;*/
  width: 80%;
  font-size: 50px;
  margin: 50px auto 0 auto
}

.button {
  width: 200px;
  background-color: #fc4f42;
  border-radius: 30px;
  color: white;
}
</style>
